/*
 * @Author: qianmingtian
 * @Date: 2020-07-10 10:26:15
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-10 16:14:34
 * @FilePath: \qianmingtian.github.io\code\java\ExceptionTest\FinallyTest.java
 */
package ExceptionTest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

import javafx.print.Collation;
import sun.text.resources.CollationData;

public class FinallyTest {
    public static void main(String[] args) {
        // System.out.println(m());
        int i = 1;
        int a = i++;
        int b = ++i;
        Stack s = new Stack<>();

        Queue<Integer> queue = new LinkedList<>();
        queue.add(2);
        TreeSet ts = new TreeSet<>();

        Collection cc = new ArrayList();

        Iterator itNull = cc.iterator();

        /**
         * 集合结构发生变化，需要重新获取
         */
        if (itNull.hasNext()) {
            System.out.println(itNull.next());
        }

        String s1 = new String("hello");

        cc.add(s1);

        String s2 = new String("hello");

        cc.add(s2);

        cc.remove("hello");

        System.out.println(cc.size());
        Iterator it = cc.iterator();

        List ll = new ArrayList<>(34);

        ll.add(2);

        Map<String, Integer> map = new HashMap<>();
        map.put("dsad", 213);

        Set<String> set = map.keySet();
        ll.hashCode();

        for(String str: set){
            System.out.println(map.get(str));
        }

        Set<Map.Entry<String,Integer>> setMap = map.entrySet();

        for(Map.Entry<String,Integer> node : setMap){
            System.out.println(node.getKey() + "    " + node.getValue());
        }
        map.put(null,100);
        

        User q1 = new User("123");
        User q2 = new User("123");

        System.out.println(q1.hashCode());
        System.out.println(q2.hashCode());
        
        

        

    }

    // public static int m() {
    // int i = 100;
    // try {
    // return i;
    // } finally {
    // i++;
    // }
    // }
}

class User {
    String name;

    public User(String name) {
        this.name = name;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        User other = (User) obj;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

 

}
/*
 * @Author: qianmingtian
 * 
 * @Date: 2020-07-10 10:26:15
 * 
 * @LastEditors: qianmingtian
 * 
 * @LastEditTime: 2020-07-10 10:26:15
 * 
 * @FilePath: \qianmingtian.github.io\code\java\ExceptionTest\FinallyTest.java
 */
